package duhosdebuggolok;

import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;

public class SugarPainter implements Painter {

	private static BufferedImage sugarImage = null;
	private Sugar sugar;
	
	public SugarPainter(Sugar s) {
		sugar = s;
		if(sugarImage == null)
			loadImage();
	}
	
	private static void loadImage() {
		try {
			sugarImage = ImageIO.read(new File(System.getProperty("user.dir")+"\\resources\\cukor.png"));
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	@Override
	public boolean paint(Graphics2D g){
		Point coord = sugar.getCoord();
		int radius = sugar.getRadius();
		boolean eaten = sugar.isEaten();
		double scale = 0.5;
		//AffineTransform affineTransform = new AffineTransform();
		Point c = GamePanel.calculate(coord);
		//affineTransform.translate((c.x-10), (c.y-10));
		//affineTransform.scale(scale, scale);
		g.drawImage(sugarImage, c.x, c.y, null);
		if (eaten)
			return false;
		return true;
	}

}
